/**
 * Created by developer on 17-3-2.
 */
var $advanced = $("#advanced");
var $form = $(".container-client-new");
var $shady = $(".masking");
$(function () {
    //添加新客户
    $(".button-add-client").on("click", function () {
        $form.css("display", "flex");
        $shady.css("display", "block");
        $form.find(".panel_header").html('<span>添加客户</span><span class="glyphicon glyphicon-remove cancel"></span>');
        $("#save_add_next_client").css("display", "inline-block");
        $advanced.css("display","none");
    });

    //关闭添加或修改客户弹出窗
    $form.on("click", ".cancel", function () {
        $form.css("display", "none");
        $(".masking").css("display", "none");
    });

    //主页面列表点击，侧栏滑动
    $(".list .list-item").on("click", function () {
        if ($(".aside-slider-content").css("right") == "-400px") {
            $(".aside-slider-content").animate({right:0});
        } else {
            $(".aside-slider-content").animate({right:"-400px"});
        }
    });

    //关闭侧栏
    $(".aside-slider-content").find(".cancel").on("click", function () {
        $(".aside-slider-content").animate({right:"-400px"});
    });

    //新增和修改客户弹框高级属性展开收起
    $(".more-end").children(".icon").on("click", function () {
        if($advanced.css("display") == "none") {
            $(".more-end").children(".more-text").css("display", "none");
            $advanced.css("display", "block");
            $(this).html("&#xe623;");
        } else {
            $(".more-end").children(".more-text").css("display", "block");
            $advanced.css("display", "none");
            $(this).html("&#xe605;");
        }
    });

    //点击修改按钮，弹出修改窗
    $("#modify_client").on("click", function() {
        $form.css("display", "flex");
        $shady.css("display", "block");
        $form.find(".panel_header").html('<span>修改客户</span><span class="glyphicon glyphicon-remove cancel"></span>');
        $("#save_add_next_client").css("display", "none");
        $advanced.css("display","none");
    });

    //点击删除按钮
    $("#delete_client").on("click", function () {
        $(".container-delete-client").css("display", "flex");
        $shady.css("display", "block");
    })

    $(".container-delete-client").find(".cancel").on("click", function () {
        $(".container-delete-client").css("display", "none");
        $shady.css("display", "none");
    })
});
